import fetch from "node-fetch";
import https from 'https';

const options = {
    agent: new https.Agent({
        rejectUnauthorized:false
    })
}

export async function findIpByIpaddressCom(domain){
    //github.com.ipaddress.com
    
    let resp = await fetch(`https://websites.ipaddress.com/${domain}`);
    let html = await resp.text();

    let rgx = /<tr><th>IP Address<\/th><td><ul class="comma-separated"><li>((\d{1,3}\.){3}\d{1,3})<\/li><\/ul><\/td><\/tr>/i;
    let match = rgx.exec(html);

    if(match){
        return match[1];
    }
    else{
        return
    }
};

export default {
    findIpByIpaddressCom
}


